package com.ftg.learn.psi.controller;


import com.ftg.learn.psi.Dto.PurchaseParam;
import com.ftg.learn.psi.entity.PurchaseOrder;
import com.ftg.learn.psi.service.IPurchaseOrderService;
import com.ftg.learn.psi.utils.ResEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 进货订单表 前端控制器
 * </p>
 *
 * @author guoBingTong
 * @since 2022-05-18
 */
@RestController
@RequestMapping("/psi/purchase-order")
public class PurchaseOrderController {


    @Autowired
    IPurchaseOrderService iPurchaseOrderService;

    /**
     * 进货模块
     * 添加进货订单表,同时添加进货订单明细表,并添加商品的库存。
     * @param purchaseParam
     * @return
     */
    @PostMapping("/insert")
    public ResEntity insertPurchaseOrder(@RequestBody PurchaseParam purchaseParam){
        return iPurchaseOrderService.insertPurchaseOrder(purchaseParam) ?
                new ResEntity().OK() : new ResEntity().Failure();
    }
}
